how to use javascript to download a file on Chrome without Chrome auto renaming file to "download"? [duplicate]
Posted
by
user3688566
on Stack Overflow
See other posts from Stack Overflow
or by user3688566
Published on 2014-05-29T17:35:57Z
Indexed on
2014/05/29
21:27 UTC
Read the original article
Hit count: 110
This question already has an answer here:
I use javascript to generate a file and download. It seems that depending on the version of chrome, the download file names can be auto renamed to 'download'. is there a way to avoid it?
this is my code:
var link = document.createElement("a");
link.setAttribute("href", 'data:application/octet-stream,' + 'file content here');
link.setAttribute("download", 'file1.txt');
link.click();
This is not a duplicated question because i am using the latest chrome and the previously suggested hyperlink is exactly what i am using. I think chrome v34 works fine. but once my chrome autoupdated to v35, it went back to 'download' file name.
© Stack Overflow or respective owner